package com.etcn.modules.busi.appconfig.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.etcn.common.service.impl.CrudServiceImpl;
import com.etcn.modules.busi.appconfig.dao.IAppVersionInfoDao;
import com.etcn.modules.busi.appconfig.pojo.AppVersionInfo;
import com.etcn.modules.busi.appconfig.service.IAppVersionInfoService;
import com.etcn.modules.busi.dictionary.pojo.SysDict;
import com.etcn.modules.busi.dictionary.service.ISysDictService;

/**
 * @author guozc
 * @date 2018-02-27 08:35:15
 */
 @Service("appVersionInfoService")
public class AppVersionInfoServiceImpl extends CrudServiceImpl<IAppVersionInfoDao, AppVersionInfo> implements IAppVersionInfoService{

	@Autowired
	private ISysDictService sysDictService;
	 
	@Override
	public Map<String, Object> checkVersion(String version) throws Exception {
		Map<String,Object> ret = new HashMap<String,Object>();
		AppVersionInfo latestVersionInfo = dao.getLatestVersion();
		String latestVersion = latestVersionInfo.getVersion();
		if(StringUtils.isEmpty(latestVersion) || latestVersion.equals(version)){
			ret.put("needUpdate", "0");
		}else{
			ret.put("needUpdate", "1");
			ret.put("updateInfo", latestVersionInfo);
		}
		return ret;
	}

	@Override
	public Map<String, Object> getExponentEntryConfig() throws Exception {
		Map<String,Object> ret = new HashMap<String,Object>();
		List<SysDict> exponentEntryConfig = sysDictService.findListByType("exponentEntryConfig");
		ret.put("exponentEntryConfig", exponentEntryConfig);
		return ret;
	}
	    
}